﻿using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

// Token: 0x02000069 RID: 105
public class GuideDriveUI : MonoBehaviour
{
	// Token: 0x0600035C RID: 860 RVA: 0x0001545C File Offset: 0x0001365C
	private void Awake()
	{
		this.dragPos[0].AddListener(new UnityAction<Vector2>(this.OnDrag_PosX));
		this.dragPos[1].AddListener(new UnityAction<Vector2>(this.OnDrag_PosY));
		this.dragPos[2].AddListener(new UnityAction<Vector2>(this.OnDrag_PosZ));
		this.dragRot[0].AddListener(new UnityAction<Vector2>(this.OnDrag_RotX));
		this.dragRot[1].AddListener(new UnityAction<Vector2>(this.OnDrag_RotY));
		this.dragRot[2].AddListener(new UnityAction<Vector2>(this.OnDrag_RotZ));
		this.dragScl[0].AddListener(new UnityAction<Vector2>(this.OnDrag_SclX));
		this.dragScl[1].AddListener(new UnityAction<Vector2>(this.OnDrag_SclY));
		this.dragScl[2].AddListener(new UnityAction<Vector2>(this.OnDrag_SclZ));
		this.inputPos[0].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_PosX));
		this.inputPos[1].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_PosY));
		this.inputPos[2].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_PosZ));
		this.inputRot[0].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_RotX));
		this.inputRot[1].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_RotY));
		this.inputRot[2].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_RotZ));
		this.inputScl[0].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_SclX));
		this.inputScl[1].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_SclY));
		this.inputScl[2].onEndEdit.AddListener(new UnityAction<string>(this.OnInputField_SclZ));
	}

	// Token: 0x0600035D RID: 861 RVA: 0x00015658 File Offset: 0x00013858
	public void Setup(Vector3 pos, Vector3 eul, Vector3 scl, UnityAction<Vector3, Vector3, Vector3> onMoveAct)
	{
		this.val_pos = pos;
		this.val_eul = eul;
		this.val_scl = scl;
		this.onMoveAct = onMoveAct;
		this.ToText();
	}

	// Token: 0x0600035E RID: 862 RVA: 0x00015680 File Offset: 0x00013880
	public void SetLimit(bool isLimitPos, Vector3 limitPosMin, Vector3 limitPosMax, bool isLimitScl, Vector3 limitSclMin, Vector3 limitSclMax)
	{
		this.isLimitPos = isLimitPos;
		this.limitPosMin = limitPosMin;
		this.limitPosMax = limitPosMax;
		this.isLimitScl = isLimitScl;
		this.limitSclMin = limitSclMin;
		this.limitSclMax = limitSclMax;
	}

	// Token: 0x0600035F RID: 863 RVA: 0x000156B0 File Offset: 0x000138B0
	public void SetUnlimit()
	{
		this.isLimitPos = false;
		this.isLimitScl = false;
	}

	// Token: 0x06000360 RID: 864 RVA: 0x000156C0 File Offset: 0x000138C0
	private void ToText()
	{
		this.inputPos[0].text = (this.val_pos.x * this.showMul_pos).ToString(this.num_format);
		this.inputPos[1].text = (this.val_pos.y * this.showMul_pos).ToString(this.num_format);
		this.inputPos[2].text = (this.val_pos.z * this.showMul_pos).ToString(this.num_format);
		this.inputRot[0].text = (this.val_eul.x * this.showMul_rot).ToString(this.num_format);
		this.inputRot[1].text = (this.val_eul.y * this.showMul_rot).ToString(this.num_format);
		this.inputRot[2].text = (this.val_eul.z * this.showMul_rot).ToString(this.num_format);
		this.inputScl[0].text = (this.val_scl.x * this.showMul_scl).ToString(this.num_format);
		this.inputScl[1].text = (this.val_scl.y * this.showMul_scl).ToString(this.num_format);
		this.inputScl[2].text = (this.val_scl.z * this.showMul_scl).ToString(this.num_format);
	}

	// Token: 0x06000361 RID: 865 RVA: 0x00015868 File Offset: 0x00013A68
	private void OnInputField_PosX(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_pos.x = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_pos);
		this.Move();
		this.inputPos[0].text = (this.val_pos.x * this.showMul_pos).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000362 RID: 866 RVA: 0x000158E0 File Offset: 0x00013AE0
	private void OnInputField_PosY(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_pos.y = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_pos);
		this.Move();
		this.inputPos[1].text = (this.val_pos.y * this.showMul_pos).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000363 RID: 867 RVA: 0x00015958 File Offset: 0x00013B58
	private void OnInputField_PosZ(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_pos.z = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_pos);
		this.Move();
		this.inputPos[2].text = (this.val_pos.z * this.showMul_pos).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000364 RID: 868 RVA: 0x000159D0 File Offset: 0x00013BD0
	private void OnInputField_RotX(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_eul.x = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_rot);
		this.Move();
		this.inputRot[0].text = (this.val_eul.x * this.showMul_rot).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000365 RID: 869 RVA: 0x00015A48 File Offset: 0x00013C48
	private void OnInputField_RotY(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_eul.y = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_rot);
		this.Move();
		this.inputRot[1].text = (this.val_eul.y * this.showMul_rot).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000366 RID: 870 RVA: 0x00015AC0 File Offset: 0x00013CC0
	private void OnInputField_RotZ(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_eul.z = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_rot);
		this.Move();
		this.inputRot[2].text = (this.val_eul.z * this.showMul_rot).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000367 RID: 871 RVA: 0x00015B38 File Offset: 0x00013D38
	private void OnInputField_SclX(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_scl.x = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_scl);
		this.Move();
		this.inputScl[0].text = (this.val_scl.x * this.showMul_scl).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000368 RID: 872 RVA: 0x00015BB0 File Offset: 0x00013DB0
	private void OnInputField_SclY(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_scl.y = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_scl);
		this.Move();
		this.inputScl[1].text = (this.val_scl.y * this.showMul_scl).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x06000369 RID: 873 RVA: 0x00015C28 File Offset: 0x00013E28
	private void OnInputField_SclZ(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		this.invoke = false;
		this.val_scl.z = GuideDriveUI.StringToFloat(str) * (1f / this.showMul_scl);
		this.Move();
		this.inputScl[2].text = (this.val_scl.z * this.showMul_scl).ToString(this.num_format);
		this.invoke = true;
	}

	// Token: 0x0600036A RID: 874 RVA: 0x00015CA0 File Offset: 0x00013EA0
	private void Move()
	{
		this.Limit();
		if (this.onMoveAct != null)
		{
			this.onMoveAct(this.val_pos, this.val_eul, this.val_scl);
		}
	}

	// Token: 0x0600036B RID: 875 RVA: 0x00015CD0 File Offset: 0x00013ED0
	private void Limit()
	{
		if (this.isLimitPos)
		{
			this.val_pos.x = Mathf.Clamp(this.val_pos.x, this.limitPosMin.x, this.limitPosMax.x);
			this.val_pos.y = Mathf.Clamp(this.val_pos.y, this.limitPosMin.y, this.limitPosMax.y);
			this.val_pos.z = Mathf.Clamp(this.val_pos.z, this.limitPosMin.z, this.limitPosMax.z);
		}
		if (this.isLimitScl)
		{
			this.val_scl.x = Mathf.Clamp(this.val_scl.x, this.limitSclMin.x, this.limitSclMax.x);
			this.val_scl.y = Mathf.Clamp(this.val_scl.y, this.limitSclMin.y, this.limitSclMax.y);
			this.val_scl.z = Mathf.Clamp(this.val_scl.z, this.limitSclMin.z, this.limitSclMax.z);
		}
	}

	// Token: 0x0600036C RID: 876 RVA: 0x00015E1C File Offset: 0x0001401C
	public void ResetButton()
	{
		this.invoke = false;
		this.val_pos = Vector3.zero;
		this.val_eul = Vector3.zero;
		this.val_scl = Vector3.one;
		this.Move();
		this.ToText();
		SystemSE.Play(SystemSE.SE.CHOICE);
		this.invoke = true;
	}

	// Token: 0x0600036D RID: 877 RVA: 0x00015E6C File Offset: 0x0001406C
	private static float StringToFloat(string str)
	{
		float result = 0f;
		try
		{
			result = float.Parse(str);
		}
		catch
		{
			result = 0f;
		}
		return result;
	}

	// Token: 0x0600036E RID: 878 RVA: 0x00015EA8 File Offset: 0x000140A8
	private void OnDrag_PosX(Vector2 move)
	{
		this.DragMove(new Vector3(this.DragToMoveFloat(move, this.dragMul_pos), 0f, 0f), Vector3.zero, Vector3.zero);
	}

	// Token: 0x0600036F RID: 879 RVA: 0x00015ED8 File Offset: 0x000140D8
	private void OnDrag_PosY(Vector2 move)
	{
		this.DragMove(new Vector3(0f, this.DragToMoveFloat(move, this.dragMul_pos), 0f), Vector3.zero, Vector3.zero);
	}

	// Token: 0x06000370 RID: 880 RVA: 0x00015F08 File Offset: 0x00014108
	private void OnDrag_PosZ(Vector2 move)
	{
		this.DragMove(new Vector3(0f, 0f, this.DragToMoveFloat(move, this.dragMul_pos)), Vector3.zero, Vector3.zero);
	}

	// Token: 0x06000371 RID: 881 RVA: 0x00015F38 File Offset: 0x00014138
	private void OnDrag_RotX(Vector2 move)
	{
		this.DragMove(Vector3.zero, new Vector3(this.DragToMoveFloat(move, this.dragMul_rot), 0f, 0f), Vector3.zero);
	}

	// Token: 0x06000372 RID: 882 RVA: 0x00015F68 File Offset: 0x00014168
	private void OnDrag_RotY(Vector2 move)
	{
		this.DragMove(Vector3.zero, new Vector3(0f, this.DragToMoveFloat(move, this.dragMul_rot), 0f), Vector3.zero);
	}

	// Token: 0x06000373 RID: 883 RVA: 0x00015F98 File Offset: 0x00014198
	private void OnDrag_RotZ(Vector2 move)
	{
		this.DragMove(Vector3.zero, new Vector3(0f, 0f, this.DragToMoveFloat(move, this.dragMul_rot)), Vector3.zero);
	}

	// Token: 0x06000374 RID: 884 RVA: 0x00015FC8 File Offset: 0x000141C8
	private void OnDrag_SclX(Vector2 move)
	{
		this.DragMove(Vector3.zero, Vector3.zero, new Vector3(this.DragToMoveFloat(move, this.dragMul_scl), 0f, 0f));
	}

	// Token: 0x06000375 RID: 885 RVA: 0x00015FF8 File Offset: 0x000141F8
	private void OnDrag_SclY(Vector2 move)
	{
		this.DragMove(Vector3.zero, Vector3.zero, new Vector3(0f, this.DragToMoveFloat(move, this.dragMul_scl), 0f));
	}

	// Token: 0x06000376 RID: 886 RVA: 0x00016028 File Offset: 0x00014228
	private void OnDrag_SclZ(Vector2 move)
	{
		this.DragMove(Vector3.zero, Vector3.zero, new Vector3(0f, 0f, this.DragToMoveFloat(move, this.dragMul_scl)));
	}

	// Token: 0x06000377 RID: 887 RVA: 0x00016058 File Offset: 0x00014258
	private float DragToMoveFloat(Vector2 move, float mul)
	{
		float num = move.x / (float)Screen.width;
		float num2 = move.y / (float)Screen.height;
		return (num + num2) * mul;
	}

	// Token: 0x06000378 RID: 888 RVA: 0x00016088 File Offset: 0x00014288
	private void DragMove(Vector3 movePos, Vector3 moveEul, Vector3 moveScl)
	{
		this.invoke = false;
		this.val_pos += movePos;
		this.val_eul += moveEul;
		this.val_scl += moveScl;
		this.Move();
		this.ToText();
		this.invoke = true;
	}

	// Token: 0x040002F2 RID: 754
	[SerializeField]
	private string num_format = "000.00";

	// Token: 0x040002F3 RID: 755
	[SerializeField]
	private float showMul_pos = 1f;

	// Token: 0x040002F4 RID: 756
	[SerializeField]
	private float showMul_rot = 1f;

	// Token: 0x040002F5 RID: 757
	[SerializeField]
	private float showMul_scl = 1f;

	// Token: 0x040002F6 RID: 758
	[SerializeField]
	private float dragMul_pos = 1f;

	// Token: 0x040002F7 RID: 759
	[SerializeField]
	private float dragMul_rot = 360f;

	// Token: 0x040002F8 RID: 760
	[SerializeField]
	private float dragMul_scl = 1f;

	// Token: 0x040002F9 RID: 761
	[SerializeField]
	private InputField[] inputPos = new InputField[3];

	// Token: 0x040002FA RID: 762
	[SerializeField]
	private InputField[] inputRot = new InputField[3];

	// Token: 0x040002FB RID: 763
	[SerializeField]
	private InputField[] inputScl = new InputField[3];

	// Token: 0x040002FC RID: 764
	[SerializeField]
	private DragInputUI[] dragPos = new DragInputUI[3];

	// Token: 0x040002FD RID: 765
	[SerializeField]
	private DragInputUI[] dragRot = new DragInputUI[3];

	// Token: 0x040002FE RID: 766
	[SerializeField]
	private DragInputUI[] dragScl = new DragInputUI[3];

	// Token: 0x040002FF RID: 767
	[SerializeField]
	private Toggle modeMove;

	// Token: 0x04000300 RID: 768
	[SerializeField]
	private Toggle modeRotate;

	// Token: 0x04000301 RID: 769
	[SerializeField]
	private Toggle modeScaling;

	// Token: 0x04000302 RID: 770
	private bool invoke = true;

	// Token: 0x04000303 RID: 771
	private Vector3 val_pos;

	// Token: 0x04000304 RID: 772
	private Vector3 val_eul;

	// Token: 0x04000305 RID: 773
	private Vector3 val_scl;

	// Token: 0x04000306 RID: 774
	private bool isLimitPos;

	// Token: 0x04000307 RID: 775
	private Vector3 limitPosMin;

	// Token: 0x04000308 RID: 776
	private Vector3 limitPosMax;

	// Token: 0x04000309 RID: 777
	private bool isLimitScl;

	// Token: 0x0400030A RID: 778
	private Vector3 limitSclMin;

	// Token: 0x0400030B RID: 779
	private Vector3 limitSclMax;

	// Token: 0x0400030C RID: 780
	private UnityAction<Vector3, Vector3, Vector3> onMoveAct;
}
